package com.luck.easyfoodbatch.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.TextView;

import com.luck.easyfoodbatch.R;
import com.luck.easyfoodbatch.mvp.model.MyCouponModel;
import com.luck.easyfoodbatch.util.Tools;
import com.luck.easyrecyclerview.adapter.BaseViewHolder;
import com.luck.easyrecyclerview.adapter.RecyclerArrayAdapter;

/**
 * author：luck
 * project：LoveCare
 * package：com.tongyu.luck.lovecare.adapter
 * email：893855882@qq.com
 * data：16/8/12
 */
public class OverdueCouponAdapter extends RecyclerArrayAdapter<MyCouponModel.DataBean.ModelsBean> {
    private Context mContext;

    public OverdueCouponAdapter(Context context) {
        super(context);
        this.mContext = context;
    }

    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {

        return new CouponViewHolder(parent);
    }

    public class CouponViewHolder extends BaseViewHolder<MyCouponModel.DataBean.ModelsBean> {
        TextView tv_coupon_type, tv_coupon_money, tv_coupon_http, tv_coupon_flag, tv_time_line;

        public CouponViewHolder(ViewGroup parent) {
            super(parent, R.layout.overdue_coupon_item);
            tv_coupon_type = $(R.id.tv_coupon_type);
            tv_coupon_money = $(R.id.tv_coupon_money);
            tv_coupon_http = $(R.id.tv_coupon_http);
            tv_coupon_flag = $(R.id.tv_coupon_flag);
            tv_time_line = $(R.id.tv_time_line);
        }

        @Override
        public void setData(final MyCouponModel.DataBean.ModelsBean bean, int position) {
            int type = bean.getType();//1通用2指定店铺3指定商品
            switch (type) {
                case 1:
                    tv_coupon_type.setText("通用类");
                    tv_coupon_flag.setText("通用类优惠券");
                    break;
                case 2:
                    tv_coupon_type.setText("指定店铺");
                    tv_coupon_flag.setText("指定店铺优惠券");
                    break;
                case 3:
                    tv_coupon_type.setText("指定商品");
                    tv_coupon_flag.setText("指定商品优惠券");
                    break;
            }
            tv_time_line.setText(Tools.SubTime3(bean.getEffective_time()));
            int money = (int) bean.getDec_money();
            tv_coupon_money.setText(money + "");
            tv_coupon_http.setText(bean.getTitle());
        }
    }
}
